//
//  StatusBottom.swift
//  SinaWeibo25
//
//  Created by apple on 16/3/15.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit
import SnapKit
class StatusBottom: UIView {
    @objc private func repostbtnclick() {
        let temp = tempcontroller()
        
        temp.hidesBottomBarWhenPushed = true
        navController()?.pushViewController(temp, animated: true)
    }
    
    
//    重写构造方法
    override init(frame: CGRect) {
        super.init(frame: frame)
        setUI()
    }
//    默认实现报错
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
//    MARK: 设置UI
    private func setUI() {
    backgroundColor = UIColor(white: 0.90, alpha: 1)

        addSubview(repostbtn)
        addSubview(commentBtn)
        addSubview(ohYeah)
        
        
        //三个按钮 平分视图
        repostbtn.snp_makeConstraints { (make) -> Void in
            make.top.bottom.left.equalTo(self)
        }
        
        commentBtn.snp_makeConstraints { (make) -> Void in
            make.top.bottom.equalTo(self)
            make.left.equalTo(repostbtn.snp_right)
            make.width.equalTo(repostbtn.snp_width)
        }
        
        ohYeah.snp_makeConstraints { (make) -> Void in
            make.top.bottom.right.equalTo(self)
            make.left.equalTo(commentBtn.snp_right)
            make.width.equalTo(commentBtn.snp_width)
        }
        let sep1 = sepview()
        
        let sep2 = sepview()
        
        addSubview(sep1)
        addSubview(sep2)
        
        let w:CGFloat = 0.4
        
        sep1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(repostbtn.snp_right)
            //黄金分割比 1 : 0.618
            make.height.equalTo(self.snp_height).multipliedBy(0.4)
            make.centerY.equalTo(self.snp_centerY)
            //设置宽度
            make.width.equalTo(w)
            
        }
        
        sep2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            make.height.equalTo(self.snp_height).multipliedBy(0.4)
            make.centerY.equalTo(self.snp_centerY)
            //设置宽度
            make.width.equalTo(w)
        }
        //添加按钮的监听事件
        repostbtn.addTarget(self, action: "repostbtnclick", forControlEvents: .TouchUpInside)
    }
//    分割线试图
    private func sepview()->UIView {
        let lineview = UIView()
        
        lineview.backgroundColor = UIColor.lightGrayColor()
        
        return lineview
    }
    
//    懒加载 
    private lazy var repostbtn: UIButton = UIButton.buttonWithtitle("转发", backImageName: nil, textColor: UIColor.darkGrayColor(), fontsize: 12, imageName: "timeline_icon_retweet")
    private lazy var commentBtn: UIButton = UIFactory.buttonWithtitle("评论", backImageName: nil, textColor: UIColor.darkGrayColor(), fontSize: 12, imageName: "timeline_icon_comment")
    private lazy var ohYeah: UIButton = UIFactory.buttonWithtitle("点赞", backImageName: nil, textColor: UIColor.darkGrayColor(), fontSize: 12, imageName: "timeline_icon_unlike")

}
